package com.soul.server.controller;

import com.soul.server.server.SmallVideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author mdoya
 * @version 1.0
 * @description:
 */
@Slf4j
@RestController
@RequestMapping("/smallVideos")
public class SmallVideoController {

    @Autowired
    private SmallVideoService smallVideoService;

    /**
     *  视频 - 视频上传
     * @param videoThumbnail 封面视频
     * @param videoFile 视频文件
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public ResponseEntity addSmallVideos(MultipartFile videoThumbnail,MultipartFile videoFile){
        smallVideoService.addSmallVideos(videoThumbnail,videoFile);
        return ResponseEntity.ok(null);
    }

    /**
     *  查询小视频分页列表
     * @param page 码数
     * @param pagesize 每天条数
     * @return List<VideoVo>
     */
    @GetMapping
    public ResponseEntity findPageSmallVideos(@RequestParam(value = "page",defaultValue = "1") Long page,@RequestParam(value = "pagesize",defaultValue = "10")Long pagesize){
        return ResponseEntity.ok(smallVideoService.findPageSmallVideos(page,pagesize));
    }

    /**
     *  视频点赞
     * @param likeId
     * @return
     */
    @PostMapping("/{id}/like")
    public ResponseEntity like(@PathVariable("id") String likeId){
        return ResponseEntity.ok(smallVideoService.like(likeId));
    }

    /**
     *  视频点赞 - 取消
     * @param likeId
     * @return
     */
    @PostMapping("/{id}/dislike")
    public ResponseEntity dislike(@PathVariable("id") String likeId){
        return ResponseEntity.ok(smallVideoService.dislike(likeId));
    }

    /**
     *  视频用户关注
     * @param uid
     * @return
     */
    @PostMapping("/{uid}/userFocus")
    public ResponseEntity userFocus(@PathVariable("uid") String uid){
        return ResponseEntity.ok(smallVideoService.userFocus(uid));
    }

    /**
     *  视频用户关注 - 取消
     * @param uid
     * @return
     */
    @PostMapping("/{uid}/userUnFocus")
    public ResponseEntity userUnFocus(@PathVariable("uid") String uid){
        return ResponseEntity.ok(smallVideoService.userUnFocus(uid));
    }

    /**
     *  视频 - 评论列表
     * @param id
     * @return
     */
    @GetMapping("/{id}/comments")
    public ResponseEntity comments(@PathVariable("id") String id){
        return ResponseEntity.ok(smallVideoService.comments(id));
    }

}
